/*    
    OpenMheg - A free MHEG-5 library
    Copyright (C) 2008 Dharmesh Malam

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.Text;
using Core.Model.Data.Generics;
using Core.Model.Data.Variables;

namespace Core.Model.Events
{
 public class EventFactory
{

  public static Event Create(Root source, enumEvents type, Generic eventData)
  {
    switch (type)
    {
    case enumEvents.AnchorFired:
        return new AnchorFired(source, (GenericOctetString)eventData);

    case enumEvents.AsynchStopped:
        return new AsynchStopped(source);

    case enumEvents.ContentAvailable:
        return new ContentAvailable(source);

    case enumEvents.CounterTrigger:
        return new CounterTrigger(source, ((GenericInteger)eventData).Value);

    case enumEvents.CursorEnter:
        return new CursorEnter(source);

    case enumEvents.CursorLeave:
        return new CursorLeave(source);

    case enumEvents.EngineEvent:
        return new EngineEvent(source, ((GenericInteger)eventData).Value);

    case enumEvents.EntryFieldFull:
        return new EntryFieldFull(source);

    case enumEvents.FirstItemPresented:
        return new FirstItemPresented( source, ( ( GenericBoolean ) eventData ).Value );

    case enumEvents.HeadItems:
        return new HeadItems(source, ((GenericInteger)eventData).Value);

    case enumEvents.HighlightOff:
        return new HighlightOff(source);

    case enumEvents.HighlightOn:
        return new HighlightOn(source);

    case enumEvents.InteractionCompleted:
        return new InteractionCompleted(source);

    case enumEvents.IsAvailable:
        return new IsAvailable(source);

    case enumEvents.IsDeleted:
        return new IsDeleted(source);

    case enumEvents.IsDeselected:
        return new IsDeselected(source);

    case enumEvents.IsRunning:
        return new IsRunning(source);

    case enumEvents.IsSelected:
        return new IsSelected(source);

    case enumEvents.IsStopped:
        return new IsStopped(source);

    case enumEvents.ItemDeselected:
        return new ItemDeselected(source, ((GenericInteger)eventData).Value);

    case enumEvents.ItemSelected:
        return new ItemSelected(source, ((GenericInteger)eventData).Value);

    case enumEvents.LastItemPresented:
        return new LastItemPresented( source, ( ( GenericBoolean) eventData ).Value );

    case enumEvents.StreamEvent:
        return new StreamEvent(source, (GenericOctetString)eventData);

    case enumEvents.StreamPlaying:
        return new StreamPlaying(source);

    case enumEvents.StreamStopped:
        return new StreamStopped(source);

    case enumEvents.TailItems:
        return new TailItems(source, ((GenericInteger)eventData).Value);

    case enumEvents.TestEvent:
        return new TestEvent( source, ( ( GenericBoolean ) eventData ).Value );

    case enumEvents.TimerFired:
        return new TimerFired(source, ((GenericInteger)eventData).Value);

    case enumEvents.TokenMovedFrom:
        return new TokenMovedFrom(source, ((GenericInteger)eventData).Value);

    case enumEvents.TokenMovedTo:
        return new TokenMovedTo(source, ((GenericInteger)eventData).Value);

    case enumEvents.UserInput:
        return new UserInput(source, ((GenericInteger)eventData).Value);

      default:
          throw new Exception( "Unkown evnt" );
        //log.severe("EventFactory asked to create an event with unknown type - returning null");
        return null;
    }
  }
}
}
